<?php 
// +----------------------------------------------------------------------
// | RXThinkCMF框架 [ RXThinkCMF ]
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 南京RXThinkCMF研发中心
// +----------------------------------------------------------------------
// | 官方网站: http://www.rxthink.cn
// +----------------------------------------------------------------------
// | Author: 牧羊人 <1175401194@qq.com>
// +----------------------------------------------------------------------

namespace app\admin\controller;

use think\facade\Db;

class Auto
{
    /**
     * 初始化方法
     * @author 牧羊人
     * @since: 2021/12/21
     */
    public function initialize()
    {

    }	
	
    /**
     * 定时筛选为监控数
     *
     */
    public function index()
    {
        $wh = [];
        $wh[] = ['p.status','=',2];
        $wh[] = ['p.issue_date','<>',''];
        $wh[] = ['p.apply_date','<>',''];
        $wh[] = ['p.number','<>',''];
        $info = Db::name("of_patent")->alias("p")
        			->field("p.*")
                    ->join("of_patent_monitor pm","pm.patent_id=p.id","LEFT")
                    ->where($wh)
                    ->where("pm.id IS NULL")
                    ->limit(300)
                    ->select();
                    
        if(!empty($info)){
        	$this->monitor = new \app\admin\service\OfPatentMonitorService();
        	foreach ($info as $key => $value) {
        		$this->monitor->monitor($value['id']);
        	}
        }
        echo date("Y-m-d H:i:s").' over';
    }           
}